package com.bst.web.base;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bst.common.annotation.Log;
import com.bst.common.enums.BusinessType;
import com.bst.base.domain.BaseReportParamFilter;
import com.bst.base.service.IBaseReportParamFilterService;
import com.bst.common.core.controller.BaseController;
import com.bst.common.core.domain.AjaxResult;
import com.bst.common.utils.poi.ExcelUtil;
import com.bst.common.core.page.TableDataInfo;

/**
 * 报表参数过滤Controller
 * 
 * @author laoliu
 * @date 2024-10-30
 */
@Controller
@RequestMapping("/base/report/param/filter")
public class BaseReportParamFilterController extends BaseController
{
    private String prefix = "base/filter";

    @Autowired
    private IBaseReportParamFilterService baseReportParamFilterService;

    @RequiresPermissions("base:filter:view")
    @GetMapping()
    public String filter()
    {
        return prefix + "/filter";
    }

    /**
     * 查询报表参数过滤列表
     */
    @RequiresPermissions("base:filter:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BaseReportParamFilter baseReportParamFilter)
    {
        startPage();
        List<BaseReportParamFilter> list = baseReportParamFilterService.selectBaseReportParamFilterList(baseReportParamFilter);
        return getDataTable(list);
    }

    /**
     * 导出报表参数过滤列表
     */
    @RequiresPermissions("base:filter:export")
    @Log(title = "报表参数过滤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BaseReportParamFilter baseReportParamFilter)
    {
        List<BaseReportParamFilter> list = baseReportParamFilterService.selectBaseReportParamFilterList(baseReportParamFilter);
        ExcelUtil<BaseReportParamFilter> util = new ExcelUtil<BaseReportParamFilter>(BaseReportParamFilter.class);
        return util.exportExcel(list, "报表参数过滤数据");
    }

    /**
     * 新增报表参数过滤
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存报表参数过滤
     */
    @RequiresPermissions("base:filter:add")
    @Log(title = "报表参数过滤", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BaseReportParamFilter baseReportParamFilter)
    {
        return toAjax(baseReportParamFilterService.insertBaseReportParamFilter(baseReportParamFilter));
    }

    /**
     * 修改报表参数过滤
     */
    @RequiresPermissions("base:filter:edit")
    @GetMapping("/edit/{idReportParamFilter}")
    public String edit(@PathVariable("idReportParamFilter") Long idReportParamFilter, ModelMap mmap)
    {
        BaseReportParamFilter baseReportParamFilter = baseReportParamFilterService.selectBaseReportParamFilterByIdReportParamFilter(idReportParamFilter);
        mmap.put("baseReportParamFilter", baseReportParamFilter);
        return prefix + "/edit";
    }

    /**
     * 修改保存报表参数过滤
     */
    @RequiresPermissions("base:filter:edit")
    @Log(title = "报表参数过滤", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BaseReportParamFilter baseReportParamFilter)
    {
        return toAjax(baseReportParamFilterService.updateBaseReportParamFilter(baseReportParamFilter));
    }
}
